/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * <p>Project: jse2204 - Reg8
 * <p>Powered by webrx On 2022-09-14 17:00:25
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Reg8 {
    public static void main(String[] args) {
        String str = """
                package java class main
                public static void main(String[] args)
                300html
                System java 123
                """;



        str= """
                /*
                * Copyright book (c) 2006, 2022, webrx.cn All rights reserved.
                *
                */
                package cn.webrx;
                                
                import java.util.regex.Pattern;
                                
                /**
                * <p>Project: jse2204 - Reg1
                * <p>Powered by webrx On 2022-09-14 10:54:34
                *
                
                * @version 1.0
                * @since 17
                */
                public class Reg1 {
                    public static void main(String[] args) {
                        String str = "hello java19D";
                                
                        //要求检查字符串中有没有大写字母
                                
                        //原始方式
                        boolean f = false;
                        for(char c : str.toCharArray()){
                            if(c <= 'Z' && c >='A'){
                                f = true;
                                break;
                            }
                        }
                        if(f){
                            System.out.printf("%s：有大写字母%n",str);
                        }else{
                            System.out.printf("%s：没有大写字母%n",str);
                        }
                                
                        System.out.println("-----------------------------");
                                
                        //正则表达式方式
                        if(str.matches(".*[A-Z].*")){
                            System.out.printf("%s：有大写字母%n",str);
                        }else{
                            System.out.printf("%s：没有大写字母%n",str);
                        }
                                
                        if(Pattern.compile("[A-Z]").matcher(str).find()){
                            System.out.printf("%s：有大写字母%n",str);
                        }else{
                            System.out.printf("%s：没有大写字母%n",str);
                        }
                    }
                }
                                
                                
                """;

        System.out.println(str);
        System.out.println(str.lines().count());

        System.out.println("------------------------");
        //分别获取所有单词并输出
        Pattern p = Pattern.compile("[A-Za-z]{4,}");
        Matcher matcher = p.matcher(str);
        int index = 0;
        while(matcher.find()){
            System.out.printf("%d、%s%n",++index,matcher.group());
        }

    }
}
